var wrongImg="<img src='/html/images/valid/wrong.gif' align='absmiddle' />";
var rightImg="<img src='/html/images/valid/right.gif' align='absmiddle' />";
var loading = new Image();
loading.src="/html/images/loadingAnimation.gif";
$(document).ready(
	function(){			
		checkRegister();
		$("input[name='submit']").click(
				function(){
					commonCheck.checknickname($("input[name='nick_name']"));					
					var flag=1;
					$('#registForm li .inputbox span').each(
						function(){
							if($(this).attr('ok')!='ok'){
								flag=0;										
								return false;
							}
						}
					);	
					if(flag==1){
						GGSHOP.loading.show();
						return true;
					}else{
						return false;
					}
				}
		);
	}
);


function checkRegister(){
	$("input[name='nick_name']").unbind();
	$("input[name='nick_name']").blur(
		function(){
			commonCheck.checknickname(this);
		}
	); 	
}

var commonCheck={
	checknickname:function(thisA){
		if($(thisA).val().length<3){
			$(thisA).next().html(wrongImg+"At least 3 characters");	
			$(thisA).next().css('color','red');
		}else{
			$(thisA).next().html(rightImg+"Right");
			$(thisA).next().css('color','green');
			$(thisA).next().attr('ok','ok');
		}
	}
};